<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

// +--------------------------------------------------------------------------------------------------------------------
// | 目的: app 应用的路由表
// | 点评: 路由其实也是请求的一部分,属于请求接受到后的处理第一步
// |      本质是为了更灵活的控制后续响应的调用,也可以理解为调度发生器
// |
// +--------------------------------------------------------------------------------------------------------------------

Route::get('think', function () {
    return 'hello,ThinkPHP6!';
});

Route::get('hello/:name', 'index/hello');

// 注意路由注册是有优先级的,定义类型越泛的.优先级越高,同时先后顺序也决定了.先匹配的规则.优先匹配定义文件中在前面的
// 可以在`rule`方法中指定请求类型
// 完整写法
//Route::rule('new/:id', 'News/update', 'POST');

// 注册路由到News控制器的read操作
// 默认写法
//Route::rule('new/:id','News/read');


Route::get('response_hello/:name', function ($name) {
    return 'Hello,' . $name . '!';
});

// 快捷写法

// 定义GET请求路由规则+生成 URL 定义
Route::get('new/<id>','News/read')->name('new_read');
// 定义POST请求路由规则
Route::post('new/<id>','News/update');
// 定义PUT请求路由规则
Route::put('new/:id','News/update');
// 定义DELETE请求路由规则
Route::delete('new/:id','News/delete');
// 所有请求都支持的路由规则
Route::any('new/:id','News/read');

// 静态路由
Route::rule('static', 'News/readStatic');

// 静态+动态路由+额外参数
Route::rule('dynamic/:year/:month/:day', 'News/readDynamic')->append(['status' => 1, 'app_id' =>5]);


// 可选变量
Route::get('blog/:year/[:month]','Blog/archive');
// 或者
/* Route::get('blog/<year>/<month?>','Blog/archive');*/

// 完全匹配
Route::get('blog/:cate$', 'Blog/read');


// 全动态路由
//Route::rule(':year/:month/:day', 'News/readDynamic');